import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '项目',
    align: "center",
    sorter: true,
    dataIndex: 'projectId_dictText'
  },
  {
    title: '系统',
    align: "center",
    sorter: true,
    dataIndex: 'projectSystemId_dictText'
  },
  {
    title: '所属批次',
    align: "center",
    sorter: true,
    dataIndex: 'batchId_dictText'
  },
  {
    title: '需求编号',
    align: "center",
    sorter: true,
    dataIndex: 'reqCode'
  },
  {
    title: '条目编号',
    align: "center",
    sorter: true,
    dataIndex: 'itemCode_dictText'
  },
  {
    title: '需求条目名称',
    align: "center",
    sorter: true,
    dataIndex: 'reqName'
  },
  {
    title: '计划编号',
    align: "center",
    dataIndex: 'planCode'
  },
  {
    title: '需求状态',
    align: "center",
    sorter: true,
    dataIndex: 'reqStat_dictText'
  },
  {
    title: '创建人',
    align: "center",
    sorter: true,
    dataIndex: 'createBy'
  },
  {
    title: '创建时间',
    align: "center",
    sorter: true,
    dataIndex: 'createTime'
  },
  {
    title: '更新人',
    align: "center",
    sorter: true,
    dataIndex: 'updateBy'
  },
  {
    title: '更新时间',
    align: "center",
    sorter: true,
    dataIndex: 'updateTime'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "项目",
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "系统",
    field: 'projectSystemId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_system,system_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "所属批次",
    field: 'batchId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_batch,batch_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "需求编号",
    field: 'reqCode',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "条目编号",
    field: 'itemCode',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "sys_role,role_name,role_code"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目',
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目!'},
             ];
    },
  },
  {
    label: '系统',
    field: 'projectSystemId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_system,system_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入系统!'},
             ];
    },
  },
  {
    label: '所属批次',
    field: 'batchId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_batch,batch_name,id"
    },
  },
  {
    label: '需求编号',
    field: 'reqCode',
    component: 'Input',
  },
  {
    label: '条目编号',
    field: 'itemCode',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "sys_role,role_name,role_code"
    },
  },
  {
    label: '需求条目名称',
    field: 'reqName',
    component: 'Input',
  },
  {
    label: '计划编号',
    field: 'planCode',
    component: 'Input',
  },
  {
    label: '需求状态',
    field: 'reqStat',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "req_stat"
    },
  },
  {
    label: '描述',
    field: 'description',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目',order: 0,view: 'sel_search', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  projectSystemId: {title: '系统',order: 1,view: 'sel_search', type: 'string',dictTable: "tm_project_system", dictCode: 'id', dictText: 'system_name',},
  batchId: {title: '所属批次',order: 2,view: 'sel_search', type: 'string',dictTable: "tm_project_batch", dictCode: 'id', dictText: 'batch_name',},
  reqCode: {title: '需求编号',order: 3,view: 'text', type: 'string',},
  itemCode: {title: '条目编号',order: 4,view: 'list', type: 'string',dictTable: "sys_role", dictCode: 'role_code', dictText: 'role_name',},
  reqName: {title: '需求条目名称',order: 5,view: 'text', type: 'string',},
  planCode: {title: '计划编号',order: 6,view: 'text', type: 'string',},
  reqStat: {title: '需求状态',order: 7,view: 'list', type: 'string',dictCode: 'req_stat',},
  createBy: {title: '创建人',order: 9,view: 'text', type: 'string',},
  createTime: {title: '创建时间',order: 10,view: 'datetime', type: 'string',},
  updateBy: {title: '更新人',order: 11,view: 'text', type: 'string',},
  updateTime: {title: '更新时间',order: 12,view: 'datetime', type: 'string',},
};
